home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-04  |  8.8 KB  |  306 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __EVENTS__
  21. #define __EVENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __QUICKDRAW__
  30. #include <Quickdraw.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <QuickdrawText.h>                                    */
  34.  
  35. #ifndef __OSUTILS__
  36. #include <OSUtils.h>
  37. #endif
  38. /*    #include <Memory.h>                                            */
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_ALIGN_SUPPORTED
  45. #pragma options align=mac68k
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT_SUPPORTED
  49. #pragma import on
  50. #endif
  51.  
  52. typedef UInt16 EventKind;
  53.  
  54.  
  55. enum {
  56.     nullEvent                    = 0,
  57.     mouseDown                    = 1,
  58.     mouseUp                        = 2,
  59.     keyDown                        = 3,
  60.     keyUp                        = 4,
  61.     autoKey                        = 5,
  62.     updateEvt                    = 6,
  63.     diskEvt                        = 7,
  64.     activateEvt                    = 8,
  65.     osEvt                        = 15,
  66.     kHighLevelEvent                = 23
  67. };
  68.  
  69. typedef UInt16 EventMask;
  70.  
  71.  
  72. enum {
  73.     mDownMask                    = 0x0002,                        /* mouse button pressed */
  74.     mUpMask                        = 0x0004,                        /* mouse button released */
  75.     keyDownMask                    = 0x0008,                        /* key pressed */
  76.     keyUpMask                    = 0x0010,                        /* key released */
  77.     autoKeyMask                    = 0x0020,                        /* key repeatedly held down */
  78.     updateMask                    = 0x0040,                        /* window needs updating */
  79.     diskMask                    = 0x0080,                        /* disk inserted */
  80.     activMask                    = 0x0100,                        /* activate/deactivate window */
  81.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents) */
  82.     osMask                        = 0x8000,                        /* operating system events (suspend, resume) */
  83.     everyEvent                    = 0xFFFF                        /* all of the above */
  84. };
  85.  
  86. enum {
  87. /* event message equates */
  88.     charCodeMask                = 0x000000FF,
  89.     keyCodeMask                    = 0x0000FF00,
  90.     adbAddrMask                    = 0x00FF0000,
  91.     osEvtMessageMask            = 0xFF000000L,
  92. /* OS event messages.  Event (sub)code is in the high byte of the message field. */
  93.     mouseMovedMessage            = 0x00FA,
  94.     suspendResumeMessage        = 0x0001,
  95.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend */
  96.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change */
  97. };
  98.  
  99. typedef UInt16 EventModifiers;
  100.  
  101.  
  102. enum {
  103. /* modifiers */
  104.     activeFlag                    = 0x0001,                        /* Bit 0 of modifiers for activateEvt and mouseDown events */
  105.     btnState                    = 0x0080,                        /* Bit 7 of low byte is mouse button state */
  106.     cmdKey                        = 0x0100,                        /* Bit 0 of high byte */
  107.     shiftKey                    = 0x0200,                        /* Bit 1 of high byte */
  108.     alphaLock                    = 0x0400,                        /* Bit 2 of high byte */
  109.     optionKey                    = 0x0800,                        /* Bit 3 of high byte */
  110.     controlKey                    = 0x1000,                        /* Bit 4 of high byte */
  111.     rightShiftKey                = 0x2000,                        /* Bit 5 of high byte */
  112.     rightOptionKey                = 0x4000,                        /* Bit 6 of high byte */
  113.     rightControlKey                = 0x8000,                        /* Bit 7 of high byte */
  114.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown) */
  115.     btnStateBit                    = 7,                            /* state of button? */
  116.     cmdKeyBit                    = 8,                            /* command key down? */
  117.     shiftKeyBit                    = 9,                            /* shift key down? */
  118.     alphaLockBit                = 10,                            /* alpha lock down? */
  119.     optionKeyBit                = 11,                            /* option key down? */
  120.     controlKeyBit                = 12,                            /* control key down? */
  121.     rightShiftKeyBit            = 13,                            /* right shift key down? */
  122.     rightOptionKeyBit            = 14,                            /* right Option key down? */
  123.     rightControlKeyBit            = 15                            /* right Control key down? */
  124. };
  125.  
  126. struct EventRecord {
  127.     EventKind                        what;
  128.     UInt32                            message;
  129.     UInt32                            when;
  130.     Point                            where;
  131.     EventModifiers                    modifiers;
  132. };
  133. typedef struct EventRecord EventRecord;
  134.  
  135. typedef UInt32 KeyMap[4];
  136.  
  137. struct EvQEl {
  138.     QElemPtr                        qLink;
  139.     short                            qType;
  140.     EventKind                        evtQWhat;                    /* this part is identical to the EventRecord as... */
  141.     UInt32                            evtQMessage;                /* defined above */
  142.     UInt32                            evtQWhen;
  143.     Point                            evtQWhere;
  144.     EventModifiers                    evtQModifiers;
  145. };
  146. typedef struct EvQEl EvQEl;
  147.  
  148. typedef EvQEl *EvQElPtr;
  149.  
  150. typedef void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  151.  
  152. #if GENERATINGCFM
  153. typedef UniversalProcPtr GetNextEventFilterUPP;
  154. #else
  155. typedef Register68kProcPtr GetNextEventFilterUPP;
  156. #endif
  157.  
  158. enum {
  159.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc )
  160. };
  161.  
  162. #if GENERATINGCFM
  163. #define NewGetNextEventFilterProc(userRoutine)        \
  164.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  165. #else
  166. #define NewGetNextEventFilterProc(userRoutine)        \
  167.         ((GetNextEventFilterUPP) (userRoutine))
  168. #endif
  169.  
  170. #if GENERATINGCFM
  171. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  172.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  173. #else
  174. /* (*GetNextEventFilterProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  175. #endif
  176.  
  177. typedef GetNextEventFilterUPP GNEFilterUPP;
  178.  
  179. typedef pascal void (*FKEYProcPtr)(void);
  180.  
  181. #if GENERATINGCFM
  182. typedef UniversalProcPtr FKEYUPP;
  183. #else
  184. typedef FKEYProcPtr FKEYUPP;
  185. #endif
  186.  
  187. enum {
  188.     uppFKEYProcInfo = kPascalStackBased
  189. };
  190.  
  191. #if GENERATINGCFM
  192. #define NewFKEYProc(userRoutine)        \
  193.         (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  194. #else
  195. #define NewFKEYProc(userRoutine)        \
  196.         ((FKEYUPP) (userRoutine))
  197. #endif
  198.  
  199. #if GENERATINGCFM
  200. #define CallFKEYProc(userRoutine)        \
  201.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFKEYProcInfo)
  202. #else
  203. #define CallFKEYProc(userRoutine)        \
  204.         (*(userRoutine))()
  205. #endif
  206.  
  207. extern pascal UInt32 GetCaretTime( void )
  208.     TWOWORDINLINE( 0x2EB8, 0x02F4 ); /* MOVE.l $02F4,(SP) */
  209. extern pascal void SetEventMask( EventMask value )
  210.     TWOWORDINLINE( 0x31DF, 0x0144 ); /* MOVE.w (SP)+,$0144 */
  211. extern pascal EventMask GetEventMask( void )
  212.     TWOWORDINLINE( 0x3EB8, 0x0144 ); /* MOVE.w $0144,(SP) */
  213. extern pascal QHdrPtr GetEvQHdr(void)
  214.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  215. /* InterfaceLib exports GetEvQHdr, so make GetEventQueue map to that */
  216. #define GetEventQueue() GetEvQHdr()
  217. extern pascal UInt32 GetDblTime( void )
  218.     TWOWORDINLINE( 0x2EB8, 0x02F0 ); /* MOVE.l $02F0,(SP) */
  219. /* InterfaceLib exports GetDblTime, so make GetDoubleClickTime map to that */
  220. #define GetDoubleClickTime() GetDblTime()
  221. extern pascal Boolean GetNextEvent(EventMask eventMask, EventRecord *theEvent)
  222.  ONEWORDINLINE(0xA970);
  223. extern pascal Boolean WaitNextEvent(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
  224.  ONEWORDINLINE(0xA860);
  225. extern pascal Boolean EventAvail(EventMask eventMask, EventRecord *theEvent)
  226.  ONEWORDINLINE(0xA971);
  227. extern pascal void GetMouse(Point *mouseLoc)
  228.  ONEWORDINLINE(0xA972);
  229. extern pascal Boolean Button(void)
  230.  ONEWORDINLINE(0xA974);
  231. extern pascal Boolean StillDown(void)
  232.  ONEWORDINLINE(0xA973);
  233. extern pascal Boolean WaitMouseUp(void)
  234.  ONEWORDINLINE(0xA977);
  235. extern pascal void GetKeys(KeyMap theKeys)
  236.  ONEWORDINLINE(0xA976);
  237. extern pascal UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
  238.  ONEWORDINLINE(0xA9C3);
  239. extern pascal UInt32 TickCount(void)
  240.  ONEWORDINLINE(0xA975);
  241.  
  242. #if !GENERATINGCFM
  243. #pragma parameter __D0 PostEvent(__A0, __D0)
  244. #endif
  245. extern pascal OSErr PostEvent(EventKind eventNum, UInt32 eventMsg)
  246.  ONEWORDINLINE(0xA02F);
  247.  
  248. #if !GENERATINGCFM
  249. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  250. #endif
  251. extern pascal OSErr PPostEvent(EventKind eventCode, UInt32 eventMsg, EvQElPtr *qEl)
  252.  TWOWORDINLINE(0xA12F, 0x2288);
  253.  
  254. #if !GENERATINGCFM
  255. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  256. #endif
  257. extern pascal Boolean OSEventAvail(EventMask mask, EventRecord *theEvent)
  258.  TWOWORDINLINE(0xA030, 0x5240);
  259.  
  260. #if !GENERATINGCFM
  261. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  262. #endif
  263. extern pascal Boolean GetOSEvent(EventMask mask, EventRecord *theEvent)
  264.  TWOWORDINLINE(0xA031, 0x5240);
  265. extern pascal void FlushEvents(EventMask whichMask, EventMask stopMask)
  266.  TWOWORDINLINE(0x201F, 0xA032);
  267. extern pascal void SystemClick(const EventRecord *theEvent, WindowRef theWindow)
  268.  ONEWORDINLINE(0xA9B3);
  269. extern pascal void SystemTask(void)
  270.  ONEWORDINLINE(0xA9B4);
  271. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  272.  ONEWORDINLINE(0xA9B2);
  273. #if OLDROUTINENAMES
  274.  
  275. enum {
  276.     networkEvt                    = 10,
  277.     driverEvt                    = 11,
  278.     app1Evt                        = 12,
  279.     app2Evt                        = 13,
  280.     app3Evt                        = 14,
  281.     app4Evt                        = 15,
  282.     networkMask                    = 0x0400,
  283.     driverMask                    = 0x0800,
  284.     app1Mask                    = 0x1000,
  285.     app2Mask                    = 0x2000,
  286.     app3Mask                    = 0x4000,
  287.     app4Mask                    = 0x8000
  288. };
  289.  
  290. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  291. #endif
  292.  
  293. #if PRAGMA_IMPORT_SUPPORTED
  294. #pragma import off
  295. #endif
  296.  
  297. #if PRAGMA_ALIGN_SUPPORTED
  298. #pragma options align=reset
  299. #endif
  300.  
  301. #ifdef __cplusplus
  302. }
  303. #endif
  304.  
  305. #endif /* __EVENTS__ */
  306.